package cn.szsys.integration.dto;

import cn.szsys.integration.ex.BusinessException;
import lombok.Data;

import java.io.Serializable;

/**
 * 中信信用企业关联信息结果
 *
 * @author Ryan
 * @since 2025-05-17
 **/
@Data
public class ZsxyRelatedResDTO extends ZsxyInvestmentResDTO implements Serializable {

    /**
     * 转换数据
     *
     * @return {@link InvestmentRelateResDTO}
     * @author Ryan
     */
    public InvestmentRelateResDTO transform() {
        if (isSuccess()) {
            InvestmentRelateResDTO res = new InvestmentRelateResDTO();
            InvestmentRelateResDTO.BodyDTO bodyDTO = new InvestmentRelateResDTO.BodyDTO();
            InvestmentRelateResDTO.BodyDTO.DataDTO dataDTO = new InvestmentRelateResDTO.BodyDTO.DataDTO();
            bodyDTO.setData(dataDTO);
            res.setBody(bodyDTO);
            bodyDTO.setCode(0);
            bodyDTO.setMsg("SUCCESS");
            dataDTO.setResult(1);
            dataDTO.setQueryResult(getData());
            dataDTO.setResultMsg("查询成功有数据");
            res.setTimestamp(Long.valueOf(getTime()));
            res.setTicket(getOrderNo());
            return res;
        }
        throw new BusinessException(CODE_EXCEPTION_MAP.get(getCode()));
    }
}
